package io;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;

public class Student implements Serializable {
    private String name;
    private int age;
    private String gander;
    /*
      当一个属性被关键字transient修饰后，当这个对象进行序列化时，此属性值会被忽略，
      忽略不必要的属性值可以达到对象序列化瘦身的目的，
      可以减少磁盘开销或提高网络传输效率

     */
    private transient String[] otherInfo;

    public Student() {
    }

    public Student(String name, int age, String gander, String[] otherInfo) {
        this.name = name;
        this.age = age;
        this.gander = gander;
        this.otherInfo = otherInfo;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return age == student.age && Objects.equals(name, student.name) && Objects.equals(gander, student.gander) && Arrays.equals(otherInfo, student.otherInfo);
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", gander='" + gander + '\'' +
                ", otherInfo=" + Arrays.toString(otherInfo) +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getGander() {
        return gander;
    }

    public void setGander(String gander) {
        this.gander = gander;
    }

    public String[] getOtherInfo() {
        return otherInfo;
    }

    public void setOtherInfo(String[] otherInfo) {
        this.otherInfo = otherInfo;
    }

    @Override
    public int hashCode() {
        int result = Objects.hash(name, age, gander);
        result = 31 * result + Arrays.hashCode(otherInfo);
        return result;


    }
}
